package com.ljh.myaiagent.controller;

import com.ljh.myaiagent.app.LoveApp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/chat")
@Tag(name = "聊天接口", description = "恋爱心理咨询聊天接口")
@RequiredArgsConstructor
public class ChatController {
    
    private final LoveApp loveApp;
    
    @PostMapping("/send")
    @Operation(summary = "发送消息", description = "向AI发送消息并获取回复")
    public String sendMessage(@RequestParam String message, @RequestParam String chatId) {
        try {
            return loveApp.doChat(message, chatId);
        } catch (Exception e) {
            return e.getMessage();
        }
    }
    
    @PostMapping("/report")
    @Operation(summary = "获取恋爱报告", description = "发送消息并获取结构化的恋爱报告")
    public LoveApp.LoveReport getLoveReport(@RequestParam String message, @RequestParam String chatId) {
        return loveApp.doChatWithReport(message, chatId);
    }
}
